/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jhu.profiteer.data;

import java.io.Serializable;
import javax.persistence.Embeddable;

/**
 *
 * @author Jeremy
 */
@Embeddable
public class AirplaneCargoPK implements Serializable
{
  private static final long serialVersionUID = 1L;
  private Long airplaneId;
  private Long commodityId;

  public AirplaneCargoPK() {}
  public AirplaneCargoPK(Long airplaneId, Long commodityId)
  {
    this.airplaneId = airplaneId;
    this.commodityId = commodityId;
  }

  /**
   * @return the airplaneId
   */
  public Long getAirplaneId() {
    return airplaneId;
  }

  /**
   * @param airplaneId the airplaneId to set
   */
  public void setAirplaneId(Long airplaneId) {
    this.airplaneId = airplaneId;
  }

  /**
   * @return the commodityId
   */
  public Long getCommodityId() {
    return commodityId;
  }

  /**
   * @param commodityId the commodityId to set
   */
  public void setCommodityId(Long commodityId) {
    this.commodityId = commodityId;
  }

  @Override
  public boolean equals(Object object)
  {
    if(!(object instanceof AirplaneCargoPK)) return false;
    AirplaneCargoPK other = (AirplaneCargoPK)object;
    if ((null == this.getAirplaneId() && null != other.getAirplaneId()) ||
        (null != this.getAirplaneId() &&
         !this.airplaneId.equals(other.airplaneId))) {
      return false;
    }
    if ((null == this.getCommodityId() && null != other.getCommodityId()) ||
        (null != this.getCommodityId() &&
         !this.commodityId.equals(other.commodityId))) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (null != getAirplaneId() ? getAirplaneId().hashCode() : 0) +
            (null != getCommodityId() ? getCommodityId().hashCode() : 0);
    return hash;
  }

  @Override
  public String toString() {
    return "jhu.profiteer.data.AirplaneCargoPK[airplaneId=" +
            getAirplaneId() + ", commodityId=" + getCommodityId() + "]";
  }
}
